#include <iostream>
#include <algorithm>
using namespace std;
const int maxn=1005;
struct line{
	int st;
	int ed;
}l[maxn];
bool cmp(line a, line b){
	return a.ed<b.ed;
}

int main()
{
	int n; cin>>n;
	for(int i=0;i<n;++i)
		cin>>l[i].st>>l[i].ed;
	sort(l,l+n,cmp);
	
	int crt=l[0].ed;
	int ans=1;
	for(int i=1;i<n;++i){
		if(l[i].st>=crt){
			crt=l[i].ed;
			++ans;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

